/*
 * eepromData.h
 *
 * Created: 23/08/2011 11:13:21
 *  Author: guy
 */ 


#ifndef EEPROMDATA_H_
#define EEPROMDATA_H_


#include <inttypes.h>

#define MAX_MIXERS  16 //32
#define MAX_CURVE5  4
#define MAX_CURVE9  4


typedef struct EXPO_DATA {
  int8_t  expo[3][2][2];
  int8_t  drSw1;
  int8_t  drSw2;
} __attribute__((packed)) expoData_t;


typedef struct LIMIT_DATA {
  int8_t  min;
  int8_t  max;
  bool    revert;
  int16_t  offset;
} __attribute__((packed)) limitData_t;

#define MLTPX_ADD  0
#define MLTPX_MUL  1
#define MLTPX_REP  2

typedef struct MIX_DATA {
  uint8_t destCh;            //        1..NUM_CHNOUT
  uint8_t srcRaw;            //
  int8_t  weight;
  int8_t  swtch;
  uint8_t curve;             //0=symmetrisch 1=no neg 2=no pos
  uint8_t delayUp:4;
  uint8_t delayDown:4;
  uint8_t speedUp:4;         // Servogeschwindigkeit aus Tabelle (10ms Cycle)
  uint8_t speedDown:4;       // 0 nichts
  uint8_t carryTrim:1;
  uint8_t mltpx:3;           // multiplex method 0=+ 1=* 2=replace
  uint8_t mixWarn:2;         // mixer warning
  uint8_t enableFmTrim:1;
  uint8_t mixres:1;
  int8_t  sOffset;
  int8_t  res;
} __attribute__((packed)) mixData_t;


typedef struct C_SW_DATA { // Custom Switches data
  int8_t  v1; //input
  int8_t  v2; //offset
  uint8_t func;
} __attribute__((packed)) cSwData_t;

/*
typedef struct t_SafetySwData { // Custom Switches data
  int8_t  swtch;
  int8_t  val;
} __attribute__((packed)) SafetySwData;
*/


typedef struct PIPO_DATA {
  uint8_t   mdVers;
  //uint8_t   stickMode;
  uint8_t   extendedLimits:1;
  uint8_t   swashInvertELE:1;
  uint8_t   swashInvertAIL:1;
  uint8_t   swashInvertCOL:1;
  uint8_t   swashType:3;
  uint8_t	spare:1;
  uint8_t   swashCollectiveSource;
  uint8_t   swashRingValue;
  mixData_t   mixData[MAX_MIXERS];
  limitData_t limitData[NUMPPM_OUT];
  expoData_t  expoData[4];
  /*int8_t    trim[4];*/
  int8_t    curves5[MAX_CURVE5][5];
  int8_t    curves9[MAX_CURVE9][9];
  cSwData_t   customSw[NUM_CSW];
  /*uint8_t   res3[3];*/
  /*SafetySwData  safetySw[NUM_CHNOUT];
  FrSkyData frsky;*/
} __attribute__((packed)) pipoData_t;

#define TOTAL_EEPROM_USAGE (sizeof(pipo_data_t))

#endif /* EEPROMDATA_H_ */